home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBGRX100.ARJ / RESLIST.C < prev    next >
Text File  |  1992-04-10  |  2KB  |  71 lines

  1. /** 
  2.  ** RESLIST.C 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "grx.h"
  25. #include "libgrx.h"
  26. #include "grxfile.h"
  27. #include "gmalloc.h"
  28.  
  29. #include <string.h>
  30.  
  31.  
  32. void _GrAddToResList(void *data,char *name,ResList **list)
  33. {
  34.     ResList *p = _GrMalloc(sizeof(ResList) + strlen(name) + 1);
  35.  
  36.     if(p != NULL) {
  37.         strcpy(p->name,name);
  38.         p->data = data;
  39.         p->next = *list;
  40.         *list = p;
  41.     }
  42. }
  43.  
  44. void _GrRemoveFromResList(void *data,ResList **list)
  45. {
  46.     ResList *this = *list;
  47.     ResList *prev = NULL;
  48.  
  49.     while(this != NULL) {
  50.         if(this->data == data) {
  51.         *(prev ? &prev->next : list) = this->next;
  52.         _GrFree(this);
  53.         return;
  54.         }
  55.         prev = this;
  56.         this = this->next;
  57.     }
  58. }
  59.  
  60. void *_GrLookupInResList(char *name,ResList *list)
  61. {
  62.     while(list != NULL) {
  63.         if(strcmp(list->name,name) == 0)
  64.         return(list->data);
  65.         list = list->next;
  66.     }
  67.     return(NULL);
  68. }
  69.  
  70.  
  71.